package org.study.service.config;

import org.springframework.stereotype.Service;
import org.study.entity.ClusterModuleInfoEntity;
import org.study.service.IClusterModuleInfoService;

import java.util.ArrayList;
import java.util.List;

/**
 * 网络慢可以采用阿里云的下载：
 * mysql：https://mirrors.aliyun.com/mysql/MySQL-8.0
 * hadoop: https://mirrors.aliyun.com/apache/
 */
@Service("clusterModuleInfoServiceConfig")
public class ClusterModuleInfoServiceConfig implements IClusterModuleInfoService {
    @Override
    public List<ClusterModuleInfoEntity> selectByList(ClusterModuleInfoEntity entity) {
        List<ClusterModuleInfoEntity> list = new ArrayList<>();
        list.add(builder("jdk", "1.8.", "", ""));
        list.add(builder("mysql", "8.0.27", "mysql-8.0.27-el7-x86_64.tar.gz", "https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-8.0.27-el7-x86_64.tar.gz"));
        list.add(builder("hadoop", "3.4.0", "hadoop-3.4.0.tar.gz", "https://dlcdn.apache.org/hadoop/common/hadoop-3.4.0/hadoop-3.4.0.tar.gz"));
        list.add(builder("hive", "4.0.1", "apache-hive-4.0.1-bin.tar.gz", "https://dlcdn.apache.org/hive/hive-4.0.1/apache-hive-4.0.1-bin.tar.gz"));
        list.add(builder("zookeeper", "3.7.2", "apache-zookeeper-3.7.2-bin.tar.gz", "https://dlcdn.apache.org/zookeeper/zookeeper-3.7.2/apache-zookeeper-3.7.2-bin.tar.gz"));
        list.add(builder("spark", "3.5.6", "spark-3.5.6-bin-hadoop3.tgz", "https://dlcdn.apache.org/spark/spark-3.5.6/spark-3.5.6-bin-hadoop3.tgz"));
        list.add(builder("ranger", "3.5.6", "spark-3.5.6-bin-hadoop3.tgz", "https://mirrors.aliyun.com/apache/ranger/2.5.0/apache-ranger-2.5.0.tar.gz"));
        list.add(builder("krb5-server", "1.15.1-50", "krb5-server-1.15.1-50.el7.x86_64.rpm", "https://vault.centos.org/7.9.2009/os/x86_64/Packages/krb5-server-1.15.1-50.el7.x86_64.rpm"));
        list.add(builder("rb5-workstation", "1.15.1-50", "krb5-workstation-1.15.1-50.el7.x86_64.rpm", "https://vault.centos.org/7.9.2009/os/x86_64/Packages/krb5-workstation-1.15.1-50.el7.x86_64.rpm"));
        list.add(builder("krb5-libs", "1.15.1-50", "krb5-libs-1.15.1-50.el7.x86_64.rpm", "https://vault.centos.org/7.9.2009/os/x86_64/Packages/krb5-libs-1.15.1-50.el7.x86_64.rpm"));
        list.add(builder("keyutils-libs", "1.5.8-3", "keyutils-libs-1.5.8-3.el7.x86_64.rpm", "https://vault.centos.org/7.9.2009/os/x86_64/Packages/keyutils-libs-1.5.8-3.el7.x86_64.rpm"));
        list.add(builder("libkadm5", "1.15.1-50", "libkadm5-1.15.1-50.el7.x86_64.rpm", "https://vault.centos.org/7.9.2009/os/x86_64/Packages/libkadm5-1.15.1-50.el7.x86_64.rpm"));
       // list.add(builder("", "", "", ""));
        return list;
    }

    private ClusterModuleInfoEntity builder(String moduleName, String version, String softwareName, String downUrl) {
        ClusterModuleInfoEntity entity = new ClusterModuleInfoEntity();
        entity.setClusterId(1);
        entity.setFramework("x86");
        entity.setContent("每个组件功能的说明");
        entity.setModuleName(moduleName);
        entity.setVersion(version);
        entity.setSoftwareName(softwareName);
        entity.setDownUrl(downUrl);
        return entity;
    }

}
